﻿; !
(function () {
	core = {
		frame: function (params) {
			layer.open({
				type: 2,
				title: params.title,
				shadeClose: false,
				shade: 0.5,
				btn: params.btns,
				area: params.area,
				content: params.url,
				success: function (layero, index) {
					if (params.onload)
						params.onload(layero, index);
				},
				yes: function (index, layero) {
					if (params.success)
						params.success(index, layero);
				},
				cancel: function (index, layero) {
					if (params.cancel)
						params.cancel(index, layero);
				}
			});
		},
		exgrid:function(params){
			coreui.grid({
				id:params.id,
				obj:params.obj,
				search:params.search,
				checkbox:params.checkbox,
				rownumber:params.rownumber,
				size:params.size,
				pagesize:params.pagesize,
				index:params.index,
				pager:params.pager,
				key:params.key,
				columns: params.columns
			});
			if(params.buttons&&params.buttons.length>0){
				for(var i=0;i<params.buttons.length;i++){
					var item=params.buttons[i];
					if(params.buttonCodes.indexOf(item.code)!=-1){
						if(!document.getElementById(item.code)){
							var btn=document.createElement("button");
							btn.setAttribute("id", item.code);
							btn.innerHTML=item.name;
							if(item.type=="nomal"){
								btn.setAttribute("class", "btn btn-bg-green");
							}else if(item.type=="del"){
								btn.setAttribute("class", "btn btn-bg-red");
							}
							coreui.on(btn,"click",item.callback);
							document.getElementById(params.btnContainer).appendChild(btn);
						}
					}
				}
			}
		}
	}
})();